#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int StrToInt(string str) {
        cin >> str;
        int arr = 0;
        int temp = 1;
        string::reverse_iterator rit = str.rbegin();
        while (rit != str.rend()) {
            if (*rit >= '0' && *rit <= '9')
            {
                arr += temp * ((*rit) - '0');
                temp *= 10;
            }
            else {
                if (rit != str.rend() - 1)
                    return 0;
            }
            if (rit == str.rend() - 1 && *rit == '-')
            {
                arr *= -1;
            }
            rit++;
        }
        return arr;
    }
};